home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2932 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.5 KB

  1. Path: dakal.demon.co.uk!richardlh
  2. From: Richard Linsley Hood <richardlh@dakal.demon.co.uk>
  3. Newsgroups: comp.lang.c++,comp.lang.pascal.delphi.misc
  4. Subject: Re: C++ with Zapp vs. Delphi
  5. Date: Sat, 20 Jan 1996 15:32:07 +0000
  6. Organization: Dakal Systems Ltd
  7. Distribution: world
  8. Message-ID: <GK+N9LA3rQAxEwdx@dakal.demon.co.uk>
  9. References: <4coar6$d4n@sun4.bham.ac.uk> <4coip7$69s@news1.usa.pipeline.com>
  10.  <DBk8wg2yqjbB083yn@iaccess.za> <4d7pmb$48c8@tigger.cc.uic.edu>
  11.  <4dk38h$gdr@merlin.delphi.com> <4dksp1$3d6c@tigger.cc.uic.edu>
  12.  <30fe666e.3349285@130.15.126.54> <4dmjt8$6sv@crc-news.doc.ca>
  13.  <30ff9519.1799465@130.15.126.54> <4doe07$4u8@crc-news.doc.ca>
  14.  <30ffe557.16481026@130.15.126.54>
  15. NNTP-Posting-Host: dakal.demon.co.uk
  16. X-NNTP-Posting-Host: dakal.demon.co.uk
  17. MIME-Version: 1.0
  18. X-Newsreader: Turnpike Version 1.10 <EdeHes6g1FnzvsX+Q8nYPyW0xw>
  19.  
  20. In article <30ffe557.16481026@130.15.126.54>, Duncan Murdoch
  21. <dmurdoch@mast.queensu.ca> writes
  22. >On 19 Jan 1996 15:39:51 GMT, Slobodan Celenkovic <slobodan@cs.unh.edu>
  23. >wrote:
  24. >
  25. >>Sorting algorithm is still in the list class (binary search, quick sort,
  26. >>..). However the item comparison shouldn't go into the list class, but
  27. >>item classes. Why? Because items "know" how to compare themselves to
  28. >>other items.
  29. >
  30. >I hate to repeat myself, but what if I want to put something into two
  31. >different lists?  Then the item has to know which list you're calling
  32. >its Compare from.  Makes a lot more sense to me to have the Compare as
  33. >a method of the list.  Then my AlphabeticalList can compare
  34. >alphabetically, and my NumericalList can compare numerically.
  35.  
  36. The method and order by which comparisons are done is determined by the 
  37. list. This is quite reasonably part of its function. It 'knows' about 
  38. which two items should be compared to determine which is larger, 
  39. smaller, etc., thus it is part of its function.
  40.  
  41. The comparison of two objects should be done by themselves, 'are you 
  42. larger, smaller than this object' thus hiding from the list how this is 
  43. done. Only an object 'knows' how it compares to another object (of the 
  44. same type). This is quite reasonably a function of the object.
  45.  
  46. Where is the problem?
  47.  
  48. You now have a generic list, capable of storing and sorting any object. 
  49. You have generic objects that are capable of being stored in lists, 
  50. queues, btrees, etc.
  51.  
  52. Why do you wish to make life more complicated that necessary?
  53.  
  54. -- 
  55. Richard Linsley Hood | Poole, Dorset UK | email: richardlh@dakal.demon.co.uk
  56. "Programming is mirroring the world, inside a computer"   Larry O'Brien 1991
  57.